/**
 * Created by aa on 2016/5/5.
 */

function numberpicker(days,minYearRate,maxYearRate,numberChangeCallBack){

    this.changeNumber=function(days,minYearRate,maxYearRate,numberChangeCallBack){
        if (minYearRate != undefined && maxYearRate != undefined && numberChangeCallBack != undefined) {
            var money = parseInt($(swiper.slides[swiper.activeIndex]).attr('valueNum'));
            operateObj= GetFormatResult.getProfitResult(days,minYearRate,maxYearRate);
            var minResult = operateObj.min(money);
            var maxResult =operateObj.max(money);
            numberChangeCallBack(minResult, maxResult);
        }
    };
    //初始化
    this.initNumberBar=function(numArray) {
        for (var i = 0; i < numArray.length; i++) {
            $(".swiper-wrapper").append('<div class="swiper-slide"  valueNum="' + numArray[i] + '"><div class="title">' + formatMoney(numArray[i],0) + '</div><div class="mark"></div></div>');
        }

        var mySwiper = new Swiper('.swiper-container', {
            pagination: '.pagination',
            paginationClickable: true,
            centeredSlides: true,
            slidesPerView: 4,
            watchActiveIndex: true,
            loop:true,
            onSlideChangeEnd: function (swiper) {
                /*$('.swiper-slide .title').css('color','blue');*/
                if (minYearRate != undefined && maxYearRate != undefined && numberChangeCallBack != undefined) {
                    var money = parseInt($(swiper.slides[swiper.activeIndex]).attr('valueNum'));
                    operateObj= GetFormatResult.getProfitResult(days,minYearRate,maxYearRate);
                    var minResult = operateObj.min(money);
                    var maxResult =operateObj.max(money);
                    numberChangeCallBack(minResult, maxResult);
                }
            }
        });

        return mySwiper;
    };

    //获取数字滚动条内容
    //起购金额
    //总金额
    //最低追加金额
    this.getNumbersByRange=function(subscriptionOrigin,financingAccount,minAppendAccount){
        var array=[100,1000,10000,100000,1000000,10000000];
        var resultArray=new Array();
       // resultArray.push(0);
        for(var i=0;i<array.length;i++){
            for(var j=1;j<=9;j++){
                if(array[i]>=minAppendAccount&& array[i]*j>=subscriptionOrigin&&array[i]*j<=financingAccount){
                    resultArray.push(array[i]*j);
                }
            }
        }
        return resultArray;
    };
}